﻿<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:model="http://schemas.ad.by/model/2010"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="model html">

  <!-- css -->

  <xsl:template match="model:html-layout" mode="css">
    <xsl:apply-templates mode="css" />
  </xsl:template>

  <xsl:template match="model:html-layout-pane[parent::model:html-layout/@mode = 'h-min-rest' and position() = 1]" mode="css">
    <style type="text/css">
      <xsl:value-of select="concat('#', generate-id(), ' { float: left; }')" />
      
      <xsl:apply-templates mode="css" />
    </style>
  </xsl:template>

  <xsl:template match="model:html-layout-pane[parent::model:html-layout/@mode = 'h-min-rest' and position() = 2]" mode="css">
    <style type="text/css">
      <xsl:value-of select="concat('#', generate-id(), ' { overflow: hidden; }')" />
      <xsl:value-of select="concat('.ie6 #', generate-id(), ' { height: 1%; }')" />

      <xsl:apply-templates mode="css" />
    </style>
  </xsl:template>

  <!-- body -->

  <xsl:template match="model:html-layout">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="model:html-layout-pane">
    <div id="{generate-id()}">
      <xsl:apply-templates />
    </div>
  </xsl:template>

</xsl:stylesheet>